{
  //1. 类的声明
  class Person {
    //属性
    name: string;
    age: number;
    alias: string = "张三";

    //方法
    //构造方法
    constructor(name: string, age: number) {
      this.name = name;
      this.age = age;
    }

    //方法
    run() {
      console.log("我可以奔跑~~");
    }

    //calculate
    calc(a: number, b: number) {
      return a + b;
    }
  }

  //实例化对象
  // let me: Person  = new Person("xiaohigh", 18);

  //输出
  // console.log(me);
  // me.run();
  // console.log(me.calc(100, 200));

  //2. 类的继承
  class Programmer extends Person {
    //编程语言
    language: string;

    constructor(name: string, age: number, language: string) {
      super(name, age); //super 指向的父类的构造方法  Person.call(this, name, age)
      this.language = language;
    }

    intro() {
      console.log(
        `我叫 ${this.name} , 今年 ${this.age} 岁, 擅长的语言是 ${this.language}`
      );
    }

    run() {
      console.log("我可以跑的很快~~~");
    }
  }

  //实例化对象
  // let zhe = new Programmer('哲', 18, "JavaScript");

  // zhe.intro();
  // zhe.run();

  //3. 类的成员修饰符
  class Girl {
    public name: string;
    protected age: number;
    private weight: number;

    constructor(name: string, age: number, weight: number) {
      this.name = name;
      this.age = age;
      this.weight = weight;
    }

    intro() {
      console.log(this.name, this.age, this.weight); //√
    }
  }

  class Child extends Girl {
    //声明一个方法
    access() {
      // access 进入 访问
      console.log(this.name); //√
      console.log(this.age); // √
      // console.log(this.weight); //x
    }
  }

  //实例化对象
  let wbb: Girl = new Girl("王冰冰", 28, 97);
  let goudan = new Child('狗蛋', 8, 25);
  goudan.access();

  // console.log(wbb.name);  //√
  // console.log(wbb.age);    // x
  // console.log(wbb.weight); //x

  // wbb.intro();
}
